import {reactive,onMounted,onBeforeUnmount} from 'vue'
interface MouseType{
    x:number
    y:number
}
const useMouse=()=>{
    const point=reactive<MouseType>({
        x:0,
        y:0
    })
    const handle=(e:MouseEvent)=>{
        point.x=e.clientX
        point.y=e.clientY
    }
    onMounted(()=>{
       document.addEventListener('mousemove',handle) 
    })
    onBeforeUnmount(()=>{
        document.removeEventListener('mousemove',handle)
    })
    return point
}
export default useMouse